﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using FbKPI.Facade;
using FbKPI.Model;

namespace FBKPI.Forms
{
    public partial class UoMDetailSetupForm : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                int ID = Convert.ToInt16(Request.QueryString["ID"]);
                if (ID != 0)
                {
                    UoMDetailFacade df = new UoMDetailFacade();
                    UoMDetail Details = df.GetUoMDetailByID(ID);

                    if (Details != null)
                    {
                        txt_idsetup.Text = Details.ID.ToString();
                        hfIdsetup.Value = Details.ID.ToString();
                        txt_descriptionsetup.Text = Details.Description;
                        //txt_listvalue.Text = Details.ListValue;

                        if (Details.UoM.Format == UoMFormat.Month)
                        {
                            txt_listvaluesetup.Style.Add(HtmlTextWriterStyle.Display, "none");
                            txt_listvaluemonthsetup.Text = Details.ListValue;
                            txt_listvaluesetup.Text = string.Empty;
                        }
                        else
                        {
                            txt_listvaluemonthsetup.Style.Add(HtmlTextWriterStyle.Display, "none");
                            txt_listvaluemonthsetup.Text = string.Empty;
                            txt_listvaluesetup.Text = Details.ListValue;
                        }

                        txt_uomtypesetup.Text = Details.UoM.Format.ToString();
                        chk_activesetup.Checked = Details.isActive;
                        txt_uomsetup.Text = Details.UoM.Description;
                        txt_uomidsetup.Value = Details.UoM.ID.ToString();
                        //txt_lastmodifieddate.Text = Details.LastModifiedDate == null ? "" : Convert.ToDateTime(Details.LastModifiedDate).ToShortDateString();
                        //txt_lastmodifiedby.Text = Details.LastModifiedBy;
                        //txt_createdate.Text = Details.CreateDate == null ? "" : Convert.ToDateTime(Details.CreateDate).ToShortDateString();
                        //txt_createby.Text = Details.CreateBy;
                    }
                }
                else
                {
                    txt_idsetup.Text = "0";
                    txt_listvaluesetup.Style.Add(HtmlTextWriterStyle.Display, "none");
                    txt_listvaluemonthsetup.Style.Add(HtmlTextWriterStyle.Display, "none");
                }

               // if (txt_id.Text == "0") btn_delete.Visible = false;
            }
        }
    }
}